package com.ruoyi.dl.uitls;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class Tool {

    //（Windows配置D:/ruoyi/uploadPath，Linux配置 /home/ruoyi/uploadPath）
    public static final String UPLOAD_PATH = "D:/ruoyi/uploadPath";

    public static synchronized String generateUniqueKey(String str) {
        Random random = new Random();
        // 随机数的量 自由定制，这是9位随机数
        Integer r = random.nextInt(900) + 100;

        // 返回  13位时间
        Long timeMillis = System.currentTimeMillis();

        // 返回  17位时间
        DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String timeStr = sdf.format(new Date());

        // 13位毫秒+9位随机数
        ///return  timeMillis + String.valueOf(r);
        // 17位时间+9位随机数
        return str + timeStr + r;
    }

    public static void main(String[] args) {
        System.out.println(generateUniqueKey(""));
        System.out.println(generateUniqueKey("").length());
    }
}
